#ifndef __GLYPHGEN_H__
#define __GLYPHGEN_H__

#include "DotFont.h"

namespace dotfont{

using Gdiplus::Font;
using Gdiplus::ColorPalette;

class GlyphGen
{
public:
	virtual void gen(wstring::const_iterator begin, const wstring::const_iterator& end,  
		int nRow, int nCol, const Size& EntrySize, const PointF& EntryOffset, 
		void* Scan0, int Stride, const Size& BmpSize, PixelFormat pf, 
		const Color& FontColor, const Color& BgColor, const ColorPalette* palette, 
		bool Antialiase) const = 0;
};

//----------------------------------------------------------------------------//

class GlyphGenFactory
{
public:
	static GlyphGen* create(const wstring& FontName, float FontSize, DotFont::Style Style);
	static GlyphGen* create(const wstring& FontName, float FontSize, DotFont::Style Style, DWORD StrokeColor);
};

//----------------------------------------------------------------------------//

class BitmapGen :
	public GlyphGen
{
public:
	virtual ~BitmapGen()
		{ delete font; }

	virtual void gen( wstring::const_iterator begin, const wstring::const_iterator& end,  
		int nRow, int nCol, const Size& EntrySize, const PointF& EntryOffset, 
		void* Scan0, int Stride, const Size& BmpSize, PixelFormat pf, 
		const Color& FontColor, const Color& BgColor, const ColorPalette* palette, 
		bool Antialiase ) const;

	const wstring& getName() const 
		{ return fontName; }
	Font& getFont() 
		{ return *font; }
	const Font& getFont() const 
		{ return *font; }
	const DotFont::Style& getStyle() const 
		{ return style; }

	float getFontSize() const 
		{ return fontSize; }

protected:
	friend class GlyphGenFactory;
	BitmapGen(const wstring& FontName, float FontSize, DotFont::Style Style);

private:
	wstring fontName;
	Font* font;
	DotFont::Style style;
	float fontSize;
};

//----------------------------------------------------------------------------//

class StrokeBmpGen :
	public GlyphGen
{
public:
	virtual ~StrokeBmpGen();

	virtual void gen( wstring::const_iterator begin, const wstring::const_iterator& end,  
		int nRow, int nCol, const Size& EntrySize, const PointF& EntryOffset, 
		void* Scan0, int Stride, const Size& BmpSize, PixelFormat pf, 
		const Color& FontColor, const Color& BgColor, const ColorPalette* palette, 
		bool Antialiase ) const;

protected:
	friend class GlyphGenFactory;
	StrokeBmpGen(const wstring& FontName, float FontSize, DotFont::Style Style, DWORD StrokeColor);

private:
	GlyphGen* gg;
	DWORD	strokeColor;
};


} // namespace dotfont

#endif // __GLYPHGEN_H__